package com.vctgo.accountSet.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vctgo.common.log.annotation.Log;
import com.vctgo.common.log.enums.BusinessType;
import com.vctgo.common.security.annotation.RequiresPermissions;
import com.vctgo.accountSet.domain.Chinas;
import com.vctgo.accountSet.service.IChinasService;
import com.vctgo.common.core.web.controller.BaseController;
import com.vctgo.common.core.web.domain.AjaxResult;
import com.vctgo.common.core.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 * 地址表Controller
 *
 * @author vctgo
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/chinas")
public class ChinasController extends BaseController
{
    @Autowired
    private IChinasService chinasService;

    /***
     * @author: lzy
     * @description: 三级联动接口
     * @params: [com.vctgo.accountSet.domain.Chinas]
     * @return: com.vctgo.common.core.web.domain.AjaxResult
     * @date: 2024/12/17 19:54
     */
    @GetMapping("/getList")
    public AjaxResult getList()
    {
        List<Chinas> list = chinasService.getList();
        return AjaxResult.success(list);
    }

    /**
     * 查询地址表列表
     */
    @RequiresPermissions("accountSet:chinas:list")
    @GetMapping("/list")
    public AjaxResult list(Chinas chinas)
    {
        IPage<Chinas> list = chinasService.selectChinasPage(chinas);
        return AjaxResult.success(list);
    }

    /**
     * 导出地址表列表
     */
    @RequiresPermissions("accountSet:chinas:export")
    @Log(title = "地址表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Chinas chinas)
    {
        List<Chinas> list = chinasService.selectChinasList(chinas);
        ExcelUtil<Chinas> util = new ExcelUtil<Chinas>(Chinas.class);
        util.exportExcel(response, list, "地址表数据");
    }

    /**
     * 获取地址表详细信息
     */
    @RequiresPermissions("accountSet:chinas:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(chinasService.selectChinasById(id));
    }

    /**
     * 新增地址表
     */
    @RequiresPermissions("accountSet:chinas:add")
    @Log(title = "地址表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Chinas chinas)
    {
        return toAjax(chinasService.insertChinas(chinas));
    }

    /**
     * 修改地址表
     */
    @RequiresPermissions("accountSet:chinas:edit")
    @Log(title = "地址表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Chinas chinas)
    {
        return toAjax(chinasService.updateChinas(chinas));
    }

    /**
     * 删除地址表
     */
    @RequiresPermissions("accountSet:chinas:remove")
    @Log(title = "地址表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chinasService.deleteChinasByIds(ids));
    }
}
